<%@page language="java" pageEncoding="UTF-8"
	contentType="text/html;charset=utf-8"%>
<%@include file="/includes/taglibs.jsp"%>
<%@page import="com.feib.stms.action.Stms9013ActionBean"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript">
    <!-- 
    $(document).ready(function() {
    	$('#doQueryBtn').click(function() {
    		var qrySYear = $('#qrySYear').val();
    		var qrySMon = $('#qrySMon').val();
    		var value1 = qrySMon.replace(/^\s+|\s+$/g,'');
    		var value2 = qrySYear.replace(/^\s+|\s+$/g,'');
    		var indate = qrySYear + '/' + qrySMon;
    		var regex_Year = /^([12])\d{3}$/;
    		var regex_Month = /^0[1-9]|10|11|12$/;
    		var errorMessage = '';
    		
    		if(value2.length <= 0){
    			
    		   errorMessage = '日期年輸入不能為空,請重新輸入!!';
    		   
    		}else{
    		
    			if(!regex_Year.test(qrySYear)){
    		
    				errorMessage = '日期年輸入有誤,格式為[yyyy/mm/dd],請重新輸入!!';
    				
    			}
    		}
    		
    		if(value1.length <= 0){
    		
    		   errorMessage = '日期月輸入不能為空,請重新輸入!!';
    		   
    		}else{
    		
    			if(!regex_Month.test(qrySMon)){
    			
    			 	errorMessage = '日期月輸入有誤,格式為[yyyy/mm/dd],請重新輸入!!';
    			 	
    			}
			}
    		
            if (errorMessage != '')
            {
                showErrorMessageDialog(errorMessage);
                return false;
            }
            $('#year_month').val(indate);//給隱藏域設定參數
            return true;
		});
		
		//回營業日設定作業
		$("#doCancelBtn").click(function() {
			$("#hidden\\.doCancelBtn").trigger('click');
		});
		
		//重置
		$("[id^='doReset']").click(function() {
			$('#qrySYear').val('');
    		$('#qrySMon').val('');
		});
	
		<c:if test="${not empty actionBean.message}">
    		showMessageDialog('<c:out value="${actionBean.message }" escapeXml="false"/>');
    	</c:if>    
    	
    	$('#doSaveSureBtn').click(function() {
			$('#messageDiv').dialog('destroy');
            $('#messageDiv').show();
            $('#messageDiv').html("確定設定營業日?" );
                
            $("#messageDiv" ).dialog({
            	title:'<span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span><strong>訊息</strong>' 
                    , width: 300
                    , resizable: false
                    , modal: true        
                    , overlay: {
                        backgroundColor: '#000',
                        opacity: 0.9
                    }
                    , buttons: {
                        Ok: function() {
                            $( this ).dialog( "close" ); 
                           	$("#hidden\\.doSaveBtn").trigger('click');
                        },
                        Cancel: function() {
                            $( this ).dialog( "close" );                          
                        }
                    }
                }).prev().addClass('ui-state-highlight');		
		});
	});
	

    //-->
    </script>
</head>
<body>



<stripes:form id="queryCalendarForm"
	beanclass="com.feib.stms.action.Stms9013ActionBean" method="post"
	onsubmit="javascript: waitingDialog({});">
	<div id="queryForm">
	<table>
		<tr>
			<td colspan="5" class="queryHeader">營業日設定作業</td>
		</tr>
		<tr>
			<th><span id="mustKeyInStar">**</span>輸入設定月份:(例如:2012/06)</th>
			<td colspan="4"><stripes:text id="qrySYear" name="qrySYear"
				size="4" maxlength="4" /> /<stripes:text id="qrySMon"
				name="qrySMon" size="2" maxlength="2" /></td>
		</tr>
		<tr>
			<td colspan="5" class="queryFunction"><stripes:hidden
				id="year_month" name="year_month" /> <stripes:submit
				id="doQueryBtn" name="doQuery" value="確定" class="formBtn" /> 
				<stripes:button name="doReset" id="doReset" value="重新輸入" /></td>
		</tr>
	</table>
	</div>
</stripes:form>

<c:if test="${! empty actionBean.cal.weekList }">
<stripes:form id="editCalendarForm" beanclass="com.feib.stms.action.Stms9013ActionBean" method="post">
<div id="listForm">
	<table id="queryResultTable">
		<thead>
			<tr>
				<td align="center" bgcolor="#008080" height="13"><font size="2"
					color="#ffffff">日</font></td>
				<td align="center" bgcolor="#008080" height="13"><font size="2"
					color="#ffffff">一</font></td>
				<td align="center" bgcolor="#008080" height="13"><font size="2"
					color="#ffffff">二</font></td>
				<td align="center" bgcolor="#008080" height="13"><font size="2"
					color="#ffffff">三</font></td>
				<td align="center" bgcolor="#008080" height="13"><font size="2"
					color="#ffffff">四</font></td>
				<td align="center" bgcolor="#008080" height="13"><font size="2"
					color="#ffffff">五</font></td>
				<td align="center" bgcolor="#008080" height="13"><font size="2"
					color="#ffffff">六</font></td>
			</tr>
		</thead>
		<tbody>
			<c:forEach var="week" items="${actionBean.cal.weekList}" varStatus="rowstat1">
				<tr>
					<c:forEach var="day" items="${week}" varStatus="rowstat2">		
					<td align="center">
						<c:if test="${!empty day.day}"><input type='checkbox' <c:if test="${!empty day.check}">${day.check }</c:if> id="businessDay${day.day }" name='checkBusinessDay[${day.day }].status' value="<c:if test='${empty day.status }'>F</c:if><c:if test='${!empty day.status }'>${day.status }</c:if>"  class="chk${day.day }"/><input type="hidden" name="checkBusinessDay[${day.day }].day" value="${day.day }"/></c:if>
						<c:choose>
						<c:when test="${day.status eq 'W'}">
						${day.day}
						</c:when>
						<c:when test="${day.status eq 'F'}">
						<font color="red">${day.day}</font>
						</c:when>
						<c:otherwise>
						${day.day}
						</c:otherwise>
						</c:choose>
					</td>
					</c:forEach>
				</tr>
			</c:forEach>
		</tbody>
		<tfoot>
			<tr>
				<td colspan="9" class="listFunction">
				<stripes:hidden name="qrySYear"/>
				<stripes:hidden name="qrySMon"/>
				<input id="doSaveSureBtn" name="doSaveSure" type="button" value="營業日設定" class="formBtn" />&nbsp;
				<stripes:submit id="doCancelBtn" name="doCancel" value="回營業日設定作業" class="formBtn"/>
				</td>
			</tr>
		</tfoot>
	</table>

</div>
	<div style="display: none;">
		<stripes:submit id="hidden.doSaveBtn" name="doSave" value="設定" class="formBtn"/>				
	</div>
</stripes:form>
</c:if>
<!-- 回營業日設定作業 -->	
<div style="display: none;">
<stripes:form id="hidden.editCalendarForm" beanclass="com.feib.stms.action.Stms9013ActionBean" method="post">
	<!-- 查詢條件 -->
	<stripes:hidden id="hidden.qrySYear" name="qrySYear" />
	<stripes:hidden id="hidden.qrySMon" name="qrySMon" />
	<stripes:submit id="hidden.doCancelBtn" name="doCancel" value="回營業日設定作業" class="formBtn"/>
</stripes:form>
</div>
</body>
</html>
